<?php
/**
 * Created by PhpStorm.
 * User: fangwei
 * Date: 2019-07-03
 * Time: 22:51
 */

namespace App\Http\Requests\Admin;


use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Config;
use Illuminate\Validation\Rule;

class CompanyInputDTO extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'title' => 'required|max:100',
            'linkman' => 'required|max:20',
            'company_type' => [
                'required',
                Rule::in(array_keys(Config::get('company_type')))
            ],
            'mobile' => 'required|regex:/^1[0-9]{10}$/',
            'address' => 'max:200',
            'content' => 'max:1000',
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '企业名称必须填写',
            'title.max' => '企业名称不能超过100个字符',
            'company_type.required' => '企业类型必须选择',
            'company_type.in' => '企业类型参数错误',
            'linkman.required' => '企业联系人必须填写',
            'linkman.max' => '企业联系人不能超过20个字符',
            'mobile.required' => '手机号码不能为空',
            'mobile.regex' => '请输入正确的手机号码',
            'address.max' => '地址不能超过200个字符',
            'content.max' => '企业介绍不能超过1000个字符',

        ];
    }
}